package com.example.su_shi_tan_app

import android.app.Application
import android.content.Context
import androidx.multidex.MultiDex
import com.alibaba.fastjson.parser.ParserConfig
import com.example.su_shi_tan_bas_lib.global.Latte
import com.example.su_shi_tan_core.SuShiTanRequestInterceptor
import es.dmoral.toasty.Toasty
import okhttp3.logging.HttpLoggingInterceptor

class AppEntrance : Application() {


    companion object {
        var isAppUpData = false

        var instance: AppEntrance? = null
    }


    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }

    override fun onCreate() {
        super.onCreate()
        instance = this
        Toasty.Config.getInstance().allowQueue(false).apply()
        ParserConfig.global.isSafeMode = true
        ParserConfig.global.isAutoTypeSupport = true

        val httpLoggingInterceptor = HttpLoggingInterceptor()

        httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.BODY

//        val mApiHost = if (BuildConfig.DEBUG) R.string.root_api_dev else R.string.root_api
//        val mApiHost = if (BuildConfig.DEBUG) R.string.root_apt_dev_temp else R.string.root_apt_temp

        val mApiHost = R.string.host_url_2
        Latte.getConfigurator()
            .withInterceptor(SuShiTanRequestInterceptor())
            .withInterceptor(httpLoggingInterceptor)
            .withNativeApiHost(mApiHost)
            .withLoaderDelayed(0)
            .withAppVersion(BuildConfig.VERSION_NAME)
            .configure()

//        aRouterInit()
    }

//    private fun aRouterInit() {
//
//    }

}